package Tree;
import java.util.*;
import java.util.Scanner;


	class TreeNode{
		public char val;
        public TreeNode left;
        public TreeNode right;
        public TreeNode(char val){
        	this.val=val;
        }
	}
	
     public class Tree{
     public static int i=0;
	public static TreeNode createTree(String str) {//字符串
		TreeNode root = null;                //这一段思路：先创建根，再创建左和右，
		                                     //再创建孩子的根，在创建左右。
		if(str.charAt(i)!='#') {
			root = new TreeNode (str.charAt(i));
			i++;
			root.left = createTree(str);
			root.right = createTree(str);
		}else {
			i++;
			
		}
		return root;
	}
public static void inorder(TreeNode root) {
	if(root==null)return;
	inorder(root.left);
	System.out.println(root.val+" ");
	inorder(root.right);
}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNextLine()) {
			String str = scan.nextLine();
			TreeNode root = createTree(str);
			inorder(root);
		}
		
	}
	
}

	

